package income

import (
	"context"
	"database/sql"
	"github.com/google/wire"
	"sieve_admin_server_userpass/app/dao/util"
	"sieve_admin_server_userpass/app/schema"
	"sieve_admin_server_userpass/lib/mysql"
)

var (
	IncomeStatisticsSet = wire.NewSet(wire.Struct(new(IncomeStatisticsRepo), "*"))
)

type IncomeStatisticsRepo struct {
	DB *mysql.DB
}

func (a *IncomeStatisticsRepo) Create(ctx context.Context, items map[string]interface{}) error {

	_, err := util.Create(ctx, IncomeStatistics{}.TableName(), a.DB, items)
	return err
}

func (a *IncomeStatisticsRepo) ExecRaw(ctx context.Context, querySQL string) (sql.Result, error) {

	return util.ExecRaw(ctx, a.DB, querySQL)
}

func (a *IncomeStatisticsRepo) Update(ctx context.Context, reqArgs map[string]interface{}, repKeys map[string]interface{}) error {

	return util.Update(ctx, IncomeStatistics{}.TableName(), a.DB, reqArgs, repKeys)
}

func (a *IncomeStatisticsRepo) Query(ctx context.Context, reqArgs map[string]interface{}, p schema.PaginationParam, repKeys []string) (interface{}, error) {

	return util.Query(ctx, IncomeStatistics{}, a.DB, reqArgs, p, repKeys)
}

func (a *IncomeStatisticsRepo) QueryRaw(ctx context.Context, querySQL string, out interface{}) ([]interface{}, error) {

	return util.QueryRaw(ctx, a.DB, querySQL, out)
}
